package com.example.demo.service;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.demo.bean.CmsRecord;
import com.example.demo.mapper.CmsRecordMapper;

@Service
public class CmsRecordService {
	
	@Autowired
	private CmsRecordMapper recordMapper;
	
	public void insert(String idCard,String pName,
			String hCategory,String tel,int pPay) {
			String id = UUID.randomUUID().toString();
			CmsRecord record = new CmsRecord(id,idCard,pName,
					hCategory,tel, pPay);
			recordMapper.insert(record);
	}
	
	public int deleteById(String idCard) {
		return recordMapper.deleteByPrimaryKey(idCard);
	}
	
	public void saveOrUpdate(CmsRecord record) {
		recordMapper.updateByPrimaryKey(record);
	}

	public List<CmsRecord> findAll(){
		return recordMapper.selectAll();
	}
	
	public CmsRecord selectById(String idCard) {
		return recordMapper.selectByPrimaryKey(idCard);
	}
}
